﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using Zoomtel.Auth.Mvc.Attributes;
using Zoomtel.Entity;
using Zoomtel.Entity.BIZ;
using Zoomtel.Persist.BIZ.Models;
using Zoomtel.Service.BIZ;
using Zoomtel.Web.Controllers;

namespace Zoomtel.Web.Areas.BIZ.Controllers
{
    public class ItemPromotionController : BizModuleController
    {
        [HttpPost]
        [AllowAnonymous]
        [Description("点击记录新增")]
        public Task<IResultModel> Add(ItemPromotionEntity model)
        {
           
            model.IPAddr=this.HttpContext.Connection.RemoteIpAddress.ToString();
            model.SettleFlag = "0";//未结算
            return _itemPromotionService.Add(model);
        }

        ItemPromotionService _itemPromotionService;
        public ItemPromotionController(ItemPromotionService itemPromotionService)
        {
            _itemPromotionService = itemPromotionService;
        }

        [Page]
        [HttpGet]
        [Description("收益计算")]
        public IActionResult CalcProfit()
        {
            var platForm = Request.Query["platForm"].ToString();
            if (platForm != null)
            {
                platForm = platForm.ToString();
            }
            ViewData["platForm"] = platForm;
            return View();
        }

        [HttpPost]
        [Description("产品访问情况")]
        public IResultModel QueryItemPromotionTotalCountInfo(ItemPromotionQueryModel model)
        {
            return _itemPromotionService.QueryItemPromotionTotalCountInfo(model);
        }

        [HttpPost]
        [Description("待结算产品列表")]
        public async Task<IList<OptionResultModel>> QueryUnsettleItemList(ItemPromotionQueryModel model)
        {
            return await _itemPromotionService.QueryUnsettleItemList(model);

        }
    }
}
